/**
 * The multiplayer management package of the application.
 */
package fr.umlv.m2.android.quizz.multiplayer;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import fr.umlv.m2.android.quizz.R;

/**
 * This activity displays a choice to the user between create a new game or
 * join an existing game.
 * 
 * @author Gambouele Bertrand.
 * @author Viravout Alexandre.
 *
 */
public class MultiplayerActivity extends Activity {
	
	/**
	 * Button used to create a new game.
	 */
	private Button createButton;
	
	/**
	 * Button used to join an existing game.
	 */
	private Button joinButton;
	
	/**
	 * Intent used to switch to another activity.
	 */
	private Intent intent;
	
	/**
	 * Generic click handler used for buttons.
	 */
	private OnClickListener clickHandler;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.multiplayer);
		
		this.createButton = (Button)findViewById(R.id.multiplayerCreateButton);
		this.joinButton = (Button)findViewById(R.id.multiplayerJoinButton);
		
		this.clickHandler = new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.multiplayerCreateButton:
					intent = new Intent(MultiplayerActivity.this, MultiplayerJoinGameActivity.class);
					break;
					
				case R.id.multiplayerJoinButton:
					intent = new Intent(MultiplayerActivity.this, MultiplayerJoinGameActivity.class);
					break;
					
				default:
					return;
				}
				
				startActivity(intent);
			}
		};
		
		this.createButton.setOnClickListener(clickHandler);
		this.joinButton.setOnClickListener(clickHandler);
	}
}
